/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.tom.social.fetcher.crawler;

import com.torunski.crawler.filter.ILinkFilter;
import com.torunski.crawler.filter.LinkFilterUtil;
import com.torunski.crawler.filter.RegularExpressionFilter;
import com.torunski.crawler.filter.ServerFilter;
import pl.tom.social.common.sitetool.ISiteTools;
import pl.tom.social.dal.entity.Site;
import pl.tom.social.common.sitetool.SiteToolsFactory;

/**
 *
 * @author Tom
 */
public class SocialLinkFilter {

	public static ILinkFilter getFilter(Site site) {
		ILinkFilter result = null;
		result = new ServerFilter(site.getUrl());
		ISiteTools tools = SiteToolsFactory.getTools(site);
		String[] excludes = tools.getExcludes();
		for (int i = 0; i < excludes.length; i++) {
			LinkFilterUtil.and(result, LinkFilterUtil.not(new RegularExpressionFilter(excludes[i])));
		}
		return result;
	}
}
